<script src="{dede:global.cfg_templets_skin/}/js/jquery-1.11.3.min.js?v=1.0.0"></script>
<script src="{dede:global.cfg_templets_skin/}/js/jquery.easing.min.js?v=1.0.0"></script>
<script src="{dede:global.cfg_templets_skin/}/js/layer/layer.js?v=1.0.0"></script>
<script src="{dede:global.cfg_templets_skin/}/js/wow.js?v=1.0.1"></script>
<script src="{dede:global.cfg_templets_skin/}/js/swiper.min.js?v=1.0.0"></script>
<script src="{dede:global.cfg_templets_skin/}/js/index.min.js?v=1.0.1"></script>

<script>

    $(function() {
        new WOW().init();

        // 导航栏居中
        scrollNavLeft();
    })

    function scrollNavLeft() {
        var windowWidth = $(window).width();
        var conNavWrap = $('.content-nav-wrap .content-nav-con');
        if (conNavWrap.length > 0) {
            console.log('conNavWrap---->', conNavWrap);
            var curNavItem = conNavWrap.find('.content-nav-list-wrap .content-nav-item.cur'),
                curOffsetLeft = curNavItem.offset().left,
                _leftSpace = curOffsetLeft - windowWidth;
            console.log('curNavItem, curOffsetLeft---->', curNavItem, curOffsetLeft);
            if (curOffsetLeft >= windowWidth / 4) {
                console.log('3---->', 3);
                conNavWrap.scrollLeft(_leftSpace + windowWidth / 2);
            }
        }
    }

    // 首页 - 轮播图
    var swiper = new Swiper('.banner-swiper-wrap.swiper-container', {
        loop: true,
        speed: 800,
        effect: 'fade',
        initialSlide: 0,
        centeredSlides: true,
        pagination: {
            el: '.banner-pagination',
            clickable: true,
        },
        autoplay: {
            delay: 1000 * 5,
        },
    });

    // 首页 - 导航模块手机版特效
    var swiper = new Swiper('.navigate-swiper-wrap.swiper-container', {
        loop: false,
        initialSlide: 1,
        slidesPerView: 2,
        spaceBetween: 20,
        centeredSlides: true,
    });
    
    
    // 首页 - 设计师模块
    var swiper = new Swiper('.index-designer-swiper.swiper-container', {
        // loop: true,
        speed: 1000,
        slidesPerView: 'auto',
        centeredSlides: false,
        navigation: {
            prevEl: '.prev-btn-item',
            nextEl: '.next-btn-item',
        },
    });

    $(function() {
        var windowWidth = $(window).width();
        var newsContextWrap = $('.news-content .news-list-wrap .news-list-item .news-info-wrap .context-wrap');


        // 首页 - 合作伙伴模块
        var oul = $('.pc-content .partner-swiper-wrapper1 .partner-list-wrap');
        var oul2 = $('.pc-content .partner-swiper-wrapper2 .partner-list-wrap');
        var oulHtml = oul.html();
        var oulHtml2 = oul2.html();
        oul.html(oulHtml+oulHtml);
        oul2.html(oulHtml2+oulHtml2);
        var timeId = null;

        var ali = $('.pc-content .partner-swiper-wrapper1 .partner-list-wrap li');
        var ali2 = $('.pc-content .partner-swiper-wrapper2 .partner-list-wrap li');
        var aliWidth = ali.eq(0).width();
        var aliSize = ali.size();
        var aliSize2 = ali2.size();
        var ulWidth = aliWidth*aliSize;
        var ulWidth2 = aliWidth*aliSize2;
        oul.width(ulWidth); //1600px
        oul2.width(ulWidth2); //1600px
        
        var speed = -1;

        function slider(){

            if(speed<0){
                if(oul.css('left')==-ulWidth/2+'px'){
                    oul.css('left',0);
                }
                oul.css('left','+=-1px');
                if(oul2.css('left')==-ulWidth2/2+'px'){
                    oul2.css('left',0);
                }
                oul2.css('left','+=-1px');
            }

            
            if(speed>0){
                if(oul.css('left')=='0px'){
                oul.css('left',-ulWidth/2+'px');
                }
                oul.css('left','+='+speed+'px');
                if(oul2.css('left')=='0px'){
                oul2.css('left',-ulWidth2/2+'px');
                }
                oul2.css('left','+='+speed+'px');
            }
            
         }
        
        // setInterval()函数的作用是：每隔一段时间，执行该函数里的代码
        console.log('windowWidth---->', windowWidth);
        if (windowWidth > 650) {
        
            timeId = setInterval(slider,50);
        }

        $('.partner-swiper-wrapper').mouseover(function(){
            // clearInterval()函数的作用是用来清除定时器
            clearInterval(timeId);
            timeId = null;
        });

        $('.partner-swiper-wrapper').mouseout(function(){
            timeId = setInterval(slider,50);
        });

        $(window).resize(function() {
            var _width = $(window).width();
            if (_width <= 650) {
                clearInterval(timeId);
                timeId = null;
            } else {
                console.log('timeId---->', timeId);
                if (!timeId) {
                    timeId = setInterval(slider,50);
                }
            }

                
            if (_width > 768) {
                var _conWidth = $('.main-wrap .container').width();
                console.log('_conWidth---->', _conWidth);
                newsContextWrap.css('width', _conWidth / 2 + 'px');
            } else {
                newsContextWrap.css('width', '100%');
            }
            console.log('_width---->', _width);
        });

        if (windowWidth > 768) {
            var _conWidth = $('.main-wrap .container').width();
            console.log('_conWidth---->', _conWidth);
            newsContextWrap.css('width', _conWidth / 2 + 'px');
        } else {
            newsContextWrap.css('width', '100%');
        }

    });
</script>